<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 *      [PinTuXiu] (C)2001-2099 ONightjar.com Pintuxiu.com.
 *      This is NOT a freeware, use is subject to license terms
 */

class eventrule_api{
	
	public function getRules(){
		$result = pcache('r', 'eventrules');
		if(!$result){
			return $this->updateRulesCache();
		}
		return $result;
	}
	
	public function getRuleByid($eid){
		return load_db('event/eventrule')->findBy('event_id',$eid);;
	}
	

	public function updateRuleByid($eid,$data){
		load_db('event/eventrule')->update(array('event_id'=>$eid),$data);
		$this->updateRulesCache();
	}
	
	
	public function updateRulesCache(){
		$ruledb = load_db('event/eventrule');
		$result = $ruledb->findAll();
		pcache('w','eventrules',$result);
		return $result;
	}
	
}
